<include file="Public:header"/>
<script type="text/javascript" src="__WEBPUBLIC__/Admin/laydate/laydate.js"></script>
<!--主页面-->
<div id="main-content" class="content">
    <ul class="breadcrumb">
        <li><a href="/">首页</a></li>
        <li class="active"><a href="javascript:;">订单管理</a></li>
        <li class="active">订单列表</li>
    </ul>

    <div class="page-header page-header1 clearfix">
        <h3>订单管理</h3>
        <ul class="nav nav-tabs">    
            <li class="active">
                <a href="javascript:;">订单列表</a>
            </li>
        </ul>
    </div>
    <div class="search-content">
        <form action="{:U('Order/orderList',array('d_id'=>$_REQUEST['d_id']))}" method="post"class="search-form form-inline" role="form">
            <div class="form-group">
                <label class="sr-only" for="name">用户昵称</label>
                <input class="earch-input form-control" id="name" type="text" name="name" value="{$name}" placeholder="用户昵称"/>　
            </div>
            <input placeholder="请输入开始日期" name="start_time" value="{$start_time}" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" style="width: 180px;height:34px;border-radius:5px">&nbsp;&nbsp;
            <input placeholder="请输入结束日期" name="end_time" value="{$end_time}" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" style="width: 180px;height:34px;border-radius:5px">
            <style>
                #laydate_ys{
                    overflow: hidden;!important;
                }
                .laydate_body .laydate_bottom{
                    height: 40px;!important;
                }
            </style>
            <div class="form-group">
                <div class="col-sm-9">
                    <select name="status" class="form-control input-small form-control-select">
                        <option value="">订单状态...</option>
                        <option value="0" <if condition="$status eq 1">selected</if>>未支付</option>
                        <option value="1" <if condition="$status eq 2">selected</if>>已支付未处理</option>
                        <option value="1" <if condition="$status eq 2">selected</if>>已处理</option>
                        <option value="9" <if condition="$status eq 9">selected</if>>已取消</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-9">
                    <select name="reminder" class="form-control input-small form-control-select">
                        <option value="">是否催单...</option>
                        <option value="1" <if condition="$reminder eq 1">selected</if>>否</option>
                        <option value="2" <if condition="$reminder eq 2">selected</if>>是</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-9">
                    <select name="d_id" class="form-control input-small form-control-select">
                        <option value="">桌牌号...</option>
                        <volist name="desks" id="desk">
                            <option value="{$desk.d_id}" <if condition="$d_id eq $desk['d_id']">selected</if>>{$desk.title}</option>
                        </volist>
                    </select>
                </div>
            </div>
            <button type="submit" class="btn derive">查询</button>　
        </form>
    </div>
    <div class="content-box-table">
        <form action="{:U('Order/delOrder')}" method="post" class="batch-form">
            <table class="table table-striped table-framed table-hover">
                <thead>
                    <tr>
                        <th width="4%">
                            <input class="check-all" type="checkbox" />
                        </th>
                        <th>ID</th>
                        <th>订单编号</th>
                        <th>用户昵称</th>
                        <th>桌牌号</th>
                        <th>订单总价</th>
                        <th>下单时间</th>
                        <th>是否已经催单</th>
                        <th>订单状态</th>
                        <th width="10%">操作</th>
                    </tr>
                </thead>
                <tbody class="tbody">
                    <if condition="empty($list)">
                        <tr style="font-size:14px;text-align: center;"><td colspan="20">暂无数据</td></tr>
                    </if>
                    <volist name="list" id="v">
                        <tr>
                            <td><input type="checkbox" value="{$v['o_id']}" name="o_id[]"/></td>
                            <td>{$v['o_id']}</td>
                            <td>{$v.order_sn}</td>
                            <td>{$v.nick_name}</td>
                            <td>{$v['desk']}</td>
                            <td>{$v.price}</td>
                            <td>{$v['ctime']|date="Y-m-d H:i:s",###}</td>
                            <td>
                                <eq name="v['reminder']" value="1"><span style="color:red;">是</span></eq>
                                <eq name="v['reminder']" value="0"><span style="color:green;">否</span></eq>
                            </td>
                            <td>
                                <if condition="$v['is_del'] eq 1">
                                    用户已删除
                                    <else/>
                                <eq name="v['status']" value="0"><span style="color:red;">未支付</span></eq>
                                <eq name="v['status']" value="1"><span style="color:#f0c040;">已支付未处理</span></eq>
                                <eq name="v['status']" value="2"><span style="color:green;">已处理</span></eq>
                                <eq name="v['status']" value="9">已取消</eq>
                                </if>
                            </td>
                            <td>
                                <eq name="v['status']" value="0">
                                    <a title="支付" class="modify" style="cursor: pointer" onclick="up({$v['o_id']},1)">
                                        <span class="icon glyphicon glyphicon-usd"></span>
                                    </a>&nbsp;
                                </eq>
                                <eq name="v['status']" value="1">
                                    <a title="处理" class="modify" style="cursor: pointer" onclick="up({$v['o_id']},2)">
                                        <span class="icon glyphicon glyphicon-pause"></span>
                                    </a>&nbsp;
                                </eq>
                                <a href="{:U('Order/oneOrder',array('o_id'=>$v['o_id']))}" title="查看订单" class="modify">
                                    <span class="icon glyphicon glyphicon-shopping-cart"></span>
                                </a>&nbsp;

                            </td>
                        </tr>
                    </volist>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="20">
                            <div class="fr">
                                {$page}
                            </div>
                        </td>
                    </tr>
                </tfoot>
            </table>
        </form>
    </div>
</div>


<script type="text/javascript">
    $(document).ready(function(){
        //排序修改
        $("input[name='sort']").each(function(){
            var id = $(this).attr('data-id');
            var num = $(this).val();
            $(this).blur(function(){
                var sort = $(this).val();
                if(sort!=num){
                    $.post("{:U('Product/ajaxUpPro')}",{art_id:id,sort:sort},function(){},'json');
                }
            });
        });
    });
    /**修改订单状态*/
    function up(id,status){
        if(confirm("确认操作？")){
            var url = "{:U('Order/ajaxStatus')}";
            $.post(url,{'id':id,'status':status},function(data){
                if(data==1){
                    alert("修改成功");
                    window.location.reload();
                }else{
                    alert("修改失败");
                }
            });
        }
    }
</script>
<include file="Public:footer"/>
